import { ITemplate } from "@/api/service/template/types";
import { ENUM_MAJOR } from "@/enum/system.enum";

/* 字段列表 */
export const defaultFields = [
  {
    param: "salePrice",
    id: "salePrice",
    template: "",
    title: "促销价"
  },
  {
    param: "memberPrice",
    id: "memberPrice",
    template: "",
    title: "会员价"
  },
  {
    param: "stock",
    id: "stock",
    template: "",
    title: "库存"
  }
];
const formObject: ITemplate = {
  templateId: "",
  templateName: "",
  resolutionId: "",
  templateColor: "",
  templateData: null,
  imgSrc: "",
  scale: 0,
  deptId: "",
  share: "0",
  resolution: {
    resolutionId: "",
    width: 0,
    height: 0,
    description: "",
    dpi: 0,
    scale: 0,
    toRotate: 0
  },
  resolutionDesc: "",
  resolutionWidth: 0,
  resolutionHeight: 0,
  major: ENUM_MAJOR.MAIN,
  /* 关联的模板列表 */
  templateList: defaultFields,
  times: 0,
  light: "",
  frequency: 1000
};

export const form = ref<ITemplate>({
  ...formObject
});

export function resetForm() {
  formObject.templateList = [...defaultFields];
  form.value = {
    ...formObject
  };
}
export let rawParamOptions = [
  {
    label: "促销价",
    value: "salePrice",
    id: "salePrice"
  },
  {
    label: "会员价",
    value: "memberPrice",
    id: "memberPrice"
  },
  {
    label: "库存",
    value: "stock",
    id: "stock"
  }
];
export const orderList = [];
export const paramOptions = ref([...rawParamOptions]);
export const majorList = [
  {
    label: "主模板",
    value: "0"
  },
  {
    label: "副模板",
    value: "1"
  }
];
